// pages/News/addOrder/addOrder.js
var businessLogic = require('../../../utils/NetWork/Model/NewsbusinessLogic.js')
var WxParse = require('../../../utils/Component/wxParse/wxParse.js');
var common = require('../../../utils/common.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    content:[],
    title:"",
    bendanwei:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  //2.2.1查询所有学校
  onLoad: function (options) {
    let c = common.Getorgid();
    this.setData({
      orgid: c.orgid,
      userid: c.userid,
    });
    this.list();
  },
  //2.2.1
  list: function () {
    // 第二步 传参
    let params = {
      "page": 1, "num": 1000, "orgid": this.data.orgid, "userid": this.data.userid
    }
    //第三步 调用接口
    businessLogic.SchoolList(params, (res) => {
      //第五步 把获取的值，传入data
     for (let i = 0; i < res.length; i++) {
       if (res[i].id == this.data.orgid) {
         // console.log(i);
         var temp = res[0];
         res[0] = res[i];
         res[i] = temp;
       }
     }
       this.setData({
        content: res,
      }); 
      

    });

  },
  bindKeyInput: function (e) {
    this.setData({
      title: e.detail.value
    })
  },
  search2: function (event) {
    let params = { "page": 1, "num": 1000, "orgid": this.data.orgid, "userid": this.data.userid, "searchField": "title", "searchValue": "" + this.data.title + "" }
    businessLogic.SchoolList(params, (res) => {
      this.setData({
        content: res
      });
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  orderChanel: function (event) {
    //跳转
     wx.navigateTo({
      url: "../orderChanel/orderChanel?id=" + event.currentTarget.dataset.id
    }); 
  },
})